package org.imlinker.gui;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import org.imlinker.list.ListManager;
import org.imlinker.setting.Settings;

public class TrayIconListener extends MouseAdapter {

	public TrayIconListener(ListManager listManager, Settings settings,
			MainWindow mainWindow) {
		this.listManager = listManager;
		this.mainWindow = mainWindow;
		this.settings = settings;
	}

	public void mouseClicked(MouseEvent e) {
		if (e.getButton() == MouseEvent.BUTTON1) {
			boolean openFirst = settings.openFirst();
			if (!openFirst || !listManager.openFirstMessage()) {
				mainWindow.setVisible(!mainWindow.isVisible());
			}
		}
	}

	private ListManager listManager;

	private MainWindow mainWindow;

	private Settings settings;

}
